<?php

namespace App\Http\Controllers\admin\defaults;

use App\Http\Controllers\admin\defaults\BaseController;
use App\Helpers\commonFuc;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;

class AdmingroupController extends BaseController
{
    private $tpviewhead='admin.defaults.admin_group.';
    private $table='admin_group';
    function __construct(Request $thisRequest)
    {
        parent::__construct($thisRequest,$this->tpviewhead,$this->table);
    }


    function dele()
    {
        $id = $this->thisRequest->get('id');
        $ids = $this->thisRequest->get('ids');
        $ids = array_merge(explode(',', $id),explode(',', $ids));
        if(empty($ids) || in_array(1,$ids) || in_array(2,$ids)){
            if($this->thisRequest->ajax()){
                return commonFuc::data_reture_json([], 400, 'id错误');
            }else{
                return '<script>alert("id错误");window.history.go(-1);</script>';
            }
        }


        $data = $this->thisModel->whereIn('id',$ids)->delete();
        if($this->thisRequest->ajax()){

            return commonFuc::data_reture_json([], 200, '删除成功');
        }else{
            return '<script>alert("删除成功");window.history.go(-1);location.reload();</script>';
        }
    }



}